/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mireille.learning.lesson2.exceptions.esercizio4.logic;

import java.util.ArrayList;
import java.util.List;
import mireille.learning.lesson2.exceptions.esercizio4.exceptions.AnimalEliminerException;
import mireille.learning.lesson2.exceptions.esercizio4.exceptions.AnimalExisteException;

/**
 *
 * @author Luca
 */
public class Zoo {
    
    private List<String> animali = new ArrayList<>();

    public Zoo() {
    
    }

    public void addAnimale(String a) throws AnimalExisteException{
        
        if(animali.contains(a)){
            throw new AnimalExisteException(a);// lancia un oggetto di una classe derivante di exception
        }
        animali.add(a);
    }
    
    public void removeAnimale(String e) throws AnimalEliminerException {
        if(!animali.contains(e)){
           throw new AnimalEliminerException (e);
        } 
        animali.remove(e);
    }
    
}
